/**
 * Created by yan_li on 2016/11/3.
 */
public class TestLock {

    public static void main(String[] args) {
        final TestLock tt = new TestLock();
        new Thread(new Runnable() {
            @Override
            public void run() {
                tt.waitSom();
            }
        }).start();
        new Thread(new Runnable() {
            @Override
            public void run() {
                tt.waitSom();
            }
        }).start();

        try {
            Thread.sleep(20000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }


    public synchronized void waitSom() {
        try {
            System.out.println(Thread.currentThread().getName()+"");
            wait();
            System.out.println("自行了");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

}
